<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="分销商" prop="traderAccount">
        <el-select
          v-model="queryParams.traderAccount"
          placeholder="请选择"
          clearable
          size="small"
        >
          <el-option
            v-for="dict in statusOptions"
            :key="dict.trader"
            :label="dict.traderName"
            :value="dict.trader"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="充值日期" prop="opertime">
        <el-date-picker
          v-model="queryParams.opertime"
          type="date"
          format="yyyy-MM-dd"
          value-format="yyyy-MM-dd"
          placeholder="选择日期"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          v-hasPermi="['distributor:distributorRecord:query']"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="postList">
      <el-table-column label="充值时间" align="center" prop="opertime">
        <template slot-scope="scope">
          <span>{{ newDate(scope.row.opertime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="分销商" align="center" prop="traderName" />
      <el-table-column label="增加可售票数" align="center" prop="tkamount" />
      <el-table-column
        label="账户充值余额"
        align="center"
        prop="accountbalance"
      />
      <el-table-column label="操作人" align="center" prop="price1" />
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageIndex"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { getPage, querytrader } from "@/api/distributor/distributorRecord";
import utils from "../../js/index";
import elementIcons from "../../components/icons/element-icons";
export default {
  name: "DistributorRecord",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 岗位表格数据
      postList: [],
      // 状态数据字典
      statusOptions: [],
      // 查询参数
      queryParams: {
        pageIndex: 1,
        pageSize: 10,
        traderAccount: undefined
        // opertime:undefined,
      },
      // 表单参数
      form: {}
    };
  },
  created() {
    this.getList(); //未撤销订单列表
    this.getQuerytrader(); //分销商列表
  },
  methods: {
    /** 查充值记录列表 */
    getList() {
      this.loading = true;
      getPage(this.queryParams).then(response => {
        if (response.code == 200) {
          this.postList = response.rows;
          this.total = response.total;
          this.loading = false;
          // this.queryParams.traderAccount = "全部";
        } else {
          this.$message.error(response.msg);
        }
      });
    },
    /** 查分销商列表 */
    getQuerytrader() {
      this.loading = true;
      querytrader().then(response => {
        this.statusOptions = response.data;
      });
    },
    // 表单重置
    reset() {
      this.form = {
        postId: undefined,
        postCode: undefined,
        postName: undefined,
        postSort: 0,
        status: "0",
        remark: undefined
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 格式化时间
    newDate(date) {
      return utils.utils.NewDate(date);
    }
  }
};
</script>
